package com.wc.算法提高课.E第五章_数学知识.博弈论.取石子;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/6 16:32
 * @description https://www.acwing.com/problem/content/description/1323/
 */
public class Main {
    /**
     * 思路:<p>
     * 当所有堆中的石子数 > 1时候<p>
     * b = 堆数 + 石子总数 - 1 为奇数必胜<p>
     * 证明: 奇数一定可以有某个偶数的后续状态<p>
     * 堆数 > 1, 合并就好/ 取一个 > 2的堆的石子<p>
     * 堆数 = 1, 取一个石子<p>
     * 偶数状态下必然会跳转到奇数状态<p>
     * 堆数 > 1, 合并 <p>
     * 堆数 = 1, 取一个石子<p>
     * 堆数 > 1, 取一个石子, 该堆石子 > 2,<p>
     * (那就合并就好/ 取一个 > 2的堆的石子, 该堆石子 = 2, 我们把 1 取走就必胜<p>
     * 那如果初始状态有堆里面为1的呢<p>
     * 定义 a 为石子堆为 1 的堆数<p>
     * f(a, b) 表示是否为获胜的状态<p>
     * 从a中取走一石子 -> f(a - 1, b)<p>
     * 从b中取走一石子 -> f(a, b - 1)<p>
     * a内部合并 -> f(a - 2, b + (b > 0 ? 3 : 2))<p>
     * b内部合并 -> f(a, b - 1)<p>
     * a与b合并 -> f(a - 1, b + 1)<p>
     *     注意：+ - * / 优先级 > 比较符
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 55, M = 50050;
    static int[][] f = new int[N][M];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        for (int i = 0; i < N; i++) {
            Arrays.fill(f[i], -1);
        }
        while (T-- > 0) {
            n = sc.nextInt();
            int a = 0, b = 0;
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if (x == 1) a++;
                    // 表示 1堆 + 石子个数
                else b += b > 0 ? x + 1 : x;
            }
            if (dp(a, b) > 0) out.println("YES");
            else out.println("NO");
        }
        out.flush();
    }

    static int dp(int a, int b) {
        if (f[a][b] != -1) return f[a][b];
        if (a == 0) return f[a][b] = b & 1;
        if (b == 1) return dp(a + 1, 0);

        if (a > 0 && dp(a - 1, b) == 0) return f[a][b] = 1;
        if (b > 0 && dp(a, b - 1) == 0) return f[a][b] = 1;
        if (a > 1 && dp(a - 2, b + (b > 0 ? 3 : 2)) == 0) return f[a][b] = 1;
        if (a > 0 && b > 0 && dp(a - 1, b + 1) == 0) return f[a][b] = 1;

        return f[a][b] = 0;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
